const { contextBridge, ipcRenderer } = require("electron");

const events = JSON.parse(process.env.events);

contextBridge.exposeInMainWorld("electron", {
    [events.TRANSFORM]: (env) => ipcRenderer.invoke(events.TRANSFORM, env),
    [events.EXPLORER]: (env) => ipcRenderer.invoke(events.EXPLORER, env),
    [events.JUDGE_REMOTE_URL]: (env) =>
        ipcRenderer.invoke(events.JUDGE_REMOTE_URL, env),
    [events.TO_FILE_PATH]: () => process.env.toFilePath,
    [events.EXPORT_ALL]: (env) => ipcRenderer.invoke(events.EXPORT_ALL, env),
    [events.MIN_WINDOW]: () => ipcRenderer.invoke(events.MIN_WINDOW),
    [events.EXIT_WINDOW]: () => ipcRenderer.invoke(events.EXIT_WINDOW),
    [events.LISTENER_IPC]: (name, callback) => ipcRenderer.on(name, callback),
    [events.GET_APP_INFO]: () => ipcRenderer.invoke(events.GET_APP_INFO),
});
